package com.molichuxing.services.business.convertor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.molichuxing.services.business.dto.request.modify.*;
import com.molichuxing.services.business.dto.response.*;
import com.molichuxing.services.infrastructure.bean.YearlyInspectionBean;
import com.molichuxing.services.infrastructure.dto.request.create.*;
import com.molichuxing.services.infrastructure.dto.response.*;
import com.molichuxing.services.infrastructure.dto.response.CarDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;

import com.alibaba.fastjson.JSONObject;
import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.utils.DateUtil;
import com.molichuxing.services.business.dto.request.create.CarLicencePlateCreateDto;
import com.molichuxing.services.business.dto.request.create.HandoverCreateBizDto;
import com.molichuxing.services.business.dto.response.AccidentAppBizDto;
import com.molichuxing.services.business.dto.response.AccidentBizDto;
import com.molichuxing.services.business.dto.response.AccidentCarUserDto;
import com.molichuxing.services.business.dto.response.AccidentCaseAppDto;
import com.molichuxing.services.business.dto.response.AccidentCommitDto;
import com.molichuxing.services.business.dto.response.AccidentDetailDto;
import com.molichuxing.services.business.dto.response.AccidentDriveAppBizDto;
import com.molichuxing.services.business.dto.response.AccidentImageAppBizDto;
import com.molichuxing.services.business.dto.response.AccidentStatusDto;
import com.molichuxing.services.business.dto.response.CarBizDto;
import com.molichuxing.services.business.dto.response.CarCheckDto;
import com.molichuxing.services.business.dto.response.CarDetailBizDto;
import com.molichuxing.services.business.dto.response.CarFenceExceptionBizDto;
import com.molichuxing.services.business.dto.response.CarInsuranceCommercialDto;
import com.molichuxing.services.business.dto.response.CarInsuranceDetailDto;
import com.molichuxing.services.business.dto.response.CarInsuranceDto;
import com.molichuxing.services.business.dto.response.CarLicencePlateDetailDto;
import com.molichuxing.services.business.dto.response.CarLicencePlateDto;
import com.molichuxing.services.business.dto.response.CarYearlyInspectDto;
import com.molichuxing.services.business.dto.response.MaintenanceBasicBizDto;
import com.molichuxing.services.business.dto.response.MaintenanceBizDto;
import com.molichuxing.services.business.dto.response.MaintenanceInfoBizDto;
import com.molichuxing.services.business.dto.response.MaintenanceRecordBizDto;
import com.molichuxing.services.business.dto.response.PdiCheckBizDto;
import com.molichuxing.services.infrastructure.dto.request.modify.HandoverModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.InsuranceCommercialModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.InsuranceModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.LicencePlateModifyDto;
import com.molichuxing.services.infrastructure.dto.request.modify.YearlyInspectionModifyDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentCaseDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentDriveDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentDto;
import com.molichuxing.services.infrastructure.dto.response.AccidentImageDto;
import com.molichuxing.services.infrastructure.dto.response.CarDetailDto;
import com.molichuxing.services.infrastructure.dto.response.CarDto;
import com.molichuxing.services.infrastructure.dto.response.CheckDisputeDto;
import com.molichuxing.services.infrastructure.dto.response.CheckDto;
import com.molichuxing.services.infrastructure.dto.response.CheckImageDto;
import com.molichuxing.services.infrastructure.dto.response.FenceExceptionDto;
import com.molichuxing.services.infrastructure.dto.response.HandoverDto;
import com.molichuxing.services.infrastructure.dto.response.InsuranceCommercialDto;
import com.molichuxing.services.infrastructure.dto.response.InsuranceDto;
import com.molichuxing.services.infrastructure.dto.response.LicencePlateDto;
import com.molichuxing.services.infrastructure.dto.response.MaintenanceDto;
import com.molichuxing.services.infrastructure.dto.response.MaintenanceLogDto;
import com.molichuxing.services.infrastructure.dto.response.YearlyInspectionDto;
import com.molichuxing.services.property.BasicEnum;
import com.molichuxing.services.property.CarAccidentImageEnum;
import com.molichuxing.services.property.CarAccidentStatusEnum;
import com.molichuxing.services.property.CarCheckTypeEnum;
import com.molichuxing.services.property.CarInsuranceStatusEnum;
import com.molichuxing.services.property.CarInsuranceTypeEnum;
import com.molichuxing.services.property.CarYearlyInspectStatusEnum;

public class Convert {

	// 车辆检验
	public static CarCheckDto toCarCheckDto(CheckDto bean) {
		CarCheckDto beanDto = null;
		if (bean != null) {
			beanDto = new CarCheckDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}

	// 车辆检验
	public static List<CarCheckDto> toCarCheckDtoList(List<CheckDto> beanList) {
		List<CarCheckDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (CheckDto bean : beanList) {
				dtoList.add(toCarCheckDto(bean));
			}
		}

		return dtoList;
	}

	public static Paged<CarCheckDto> toPagedCarCheckDto(Paged<CheckDto> bean) {
		Paged<CarCheckDto> beanDto = null;
		if (bean != null) {
			beanDto = new Paged<CarCheckDto>();
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setList(toCarCheckDtoList(bean.getList()));
		}
		return beanDto;
	}

	public static List<CarCheckDto> toCarCheckDto(List<CheckDto> checkDtoList) {
		List<CarCheckDto> dtoList = null;
		if (checkDtoList != null && checkDtoList.size() > 0) {
			dtoList = new ArrayList<>();
			for (CheckDto bean : checkDtoList) {
				dtoList.add(toCarCheckDto(bean));
			}
		}
		return dtoList;
	}

	/******************************************** mybits-plus分页结果转换开始 *****************************/
	public static List<CarLicencePlateDto> toCarLicencePlateBeanDto(List<CarDto> beanList) {
		List<CarLicencePlateDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (CarDto bean : beanList) {
				dtoList.add(toCarLicencePlateBeanDto(bean));
			}
		}

		return dtoList;
	}

	public static CarLicencePlateDto toCarLicencePlateBeanDto(CarDto bean) {
		CarLicencePlateDto beanDto = null;
		if (bean != null) {
			beanDto = new CarLicencePlateDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}




	public static List<CarInsuranceCommercialDto> toCarInsuranceCommercialDto(List<InsuranceCommercialDto> beanList) {
		List<CarInsuranceCommercialDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (InsuranceCommercialDto bean : beanList) {
				dtoList.add(toCarInsuranceCommercialDetailDto(bean));
			}
		}

		return dtoList;
	}

	public static CarInsuranceCommercialDto toCarInsuranceCommercialDetailDto(InsuranceCommercialDto bean) {
		CarInsuranceCommercialDto beanDto = null;
		if (bean != null) {
			beanDto = new CarInsuranceCommercialDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}


	/******************************************** mybits-plus分页结果转换结束 *****************************/

	/******************************************** 车牌结果转换开始 *****************************/
	public static CarLicencePlateDetailDto toCarLicencePlateDetailBeanDto(CarDto carDto,
			LicencePlateDto licencePlateDto, YearlyInspectionDto yearlyInspectionDto) {
		CarLicencePlateDetailDto carLicencePlateDetailDto = new CarLicencePlateDetailDto();
		if(null != licencePlateDto) {
			BeanUtils.copyProperties(licencePlateDto, carLicencePlateDetailDto);
		}
		BeanUtils.copyProperties(carDto, carLicencePlateDetailDto);
		if(null != yearlyInspectionDto) {
			carLicencePlateDetailDto.setEndDate(yearlyInspectionDto.getEndDate());
		}
		return carLicencePlateDetailDto;
	}

	public static LicencePlateCreateDto toCarLicencePlateDetailDto(CarLicencePlateCreateDto bean) {
		LicencePlateCreateDto licencePlateDto = new LicencePlateCreateDto();
		BeanUtils.copyProperties(bean, licencePlateDto);
		licencePlateDto.setLicenceTime(LocalDateTime.now());
		return licencePlateDto;
	}

	public static YearlyInspectionCreateDto toYearlyInspectionDto(CarLicencePlateCreateDto bean) {
		YearlyInspectionCreateDto yearlyInspectionDto = new YearlyInspectionCreateDto();
		BeanUtils.copyProperties(bean, yearlyInspectionDto);
		DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
		yearlyInspectionDto.setEndDate(LocalDateTime.parse(bean.getEndDate() + "-01 00:00:00", df));
		return yearlyInspectionDto;
	}

	public static YearlyInspectionModifyDto toCarLicencePlateModifyDto(CarLicencePlateModifyDto bean) {
		YearlyInspectionModifyDto licencePlateDto = new YearlyInspectionModifyDto();
		BeanUtils.copyProperties(bean, licencePlateDto);
		DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
		licencePlateDto.setEndDate(LocalDateTime.parse(bean.getEndDate() + "-01 00:00:00", df));
		return licencePlateDto;
	}

	public static LicencePlateModifyDto toLicencePlateModifyDto(CarLicencePlateModifyDto bean) {
		LicencePlateModifyDto licencePlateDto = new LicencePlateModifyDto();
		BeanUtils.copyProperties(bean, licencePlateDto);
		return licencePlateDto;
	}

	/******************************************** 车牌结果转换结束 *****************************/

	/******************************************** 年检结果转换开始 *****************************/
	public static List<CarYearlyInspectDto> toCarYearlyInspectDto(List<YearlyInspectionDto> beanList,
			Map<Integer, CarDto> map, Map<Integer, Integer> logCountMap) {
		List<CarYearlyInspectDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (YearlyInspectionDto bean : beanList) {
				dtoList.add(toCarLicencePlateBeanDto(bean, map,logCountMap));
			}
		}

		return dtoList;
	}

	public static CarYearlyInspectDto toCarLicencePlateBeanDto(YearlyInspectionDto yearlyInspection,
			Map<Integer, CarDto> map,Map<Integer, Integer> logCountMap) {
		CarYearlyInspectDto beanDto = null;
		if (yearlyInspection != null) {
			beanDto = new CarYearlyInspectDto();
            Integer carId = yearlyInspection.getCarId();
            BeanUtils.copyProperties(yearlyInspection, beanDto);
			CarDto carDto = map.get(carId);
			if (null != carDto) {
				BeanUtils.copyProperties(carDto, beanDto);
			}
			beanDto.setCartId(yearlyInspection.getCarId());
			if (yearlyInspection.getEndDate().isBefore(LocalDateTime.now())) {
                beanDto.setInspectStatus(CarYearlyInspectStatusEnum.OVERDUE.getValue());
            } else {
                beanDto.setInspectStatus(CarYearlyInspectStatusEnum.NORMAL.getValue());
            }
			beanDto.setId(yearlyInspection.getId());
            Integer yearlyLogCount=0;
			if(logCountMap!=null){
                yearlyLogCount= logCountMap.get(carId);
                if(null == yearlyLogCount){
                    yearlyLogCount=0;
                }
            }
            beanDto.setYearlyLogCount(yearlyLogCount);
		}
		return beanDto;
	}

	public static YearlyInspectionBizDto toYearlyInspectionBizDto(YearlyInspectionDto yearlyInspectionDto, CarDto carDto,
																  LicencePlateDto licencePlateDto, InsuranceDto insuranceDto,
																  Integer violationCount,YearlyInspectionLogDto yearlyInspectionLogDto) {
		YearlyInspectionBizDto bizDto = null;
		if (yearlyInspectionDto != null) {
			bizDto = new YearlyInspectionBizDto();
			BeanUtils.copyProperties(yearlyInspectionDto, bizDto);
            if(carDto != null){
                bizDto.setLicencePlate(carDto.getLicencePlate());
                bizDto.setVin(carDto.getVin());
                bizDto.setVehicleId(carDto.getVehicleId());
                bizDto.setStockId(carDto.getStockId());
                bizDto.setOwnershipId(carDto.getOwnershipId());
            }

            if (yearlyInspectionDto.getEndDate().isBefore(LocalDateTime.now())) {
                bizDto.setStatus(CarYearlyInspectStatusEnum.OVERDUE.getValue());
            } else {
                bizDto.setStatus(CarYearlyInspectStatusEnum.NORMAL.getValue());
            }

			bizDto.setDrivingLicenceUrl(licencePlateDto.getDrivingLicense());
			if(insuranceDto!=null){
				bizDto.setInsureProveUrl(insuranceDto.getInsureProveImg());
			}
			bizDto.setId(yearlyInspectionDto.getId());
			bizDto.setCarId(yearlyInspectionDto.getCarId());
			bizDto.setViolationCount(violationCount);

			if(yearlyInspectionLogDto!=null){
				bizDto.setExpressNumber(yearlyInspectionLogDto.getExpressNumber());
			}
		}
		return bizDto;
	}

	public static List<YearlyInspectionLogBizDto> toYearlyInspectionLogDto(List<YearlyInspectionLogDto> yearlyInspectionLogList, CarDto carDto) {
		List<YearlyInspectionLogBizDto> dtoList = null;
		if (yearlyInspectionLogList != null && yearlyInspectionLogList.size() > 0) {
			dtoList = new ArrayList<>();
			for (YearlyInspectionLogDto bean : yearlyInspectionLogList) {
				dtoList.add(toYearlyInspectionLogBizDto(bean,carDto));
			}
		}

		return dtoList;
	}

	public static YearlyInspectionLogBizDto toYearlyInspectionLogBizDto(YearlyInspectionLogDto yearlyInspectionLog, CarDto carDto) {
		YearlyInspectionLogBizDto bizDto = null;
		if (yearlyInspectionLog != null) {
			bizDto = new YearlyInspectionLogBizDto();
			BeanUtils.copyProperties(yearlyInspectionLog, bizDto);
			BeanUtils.copyProperties(carDto, bizDto);
			bizDto.setId(yearlyInspectionLog.getId());
		}
		return bizDto;
	}

	public static List<YearlyInspectionModifyDto> toYearlyInspectionModifyDto(List<YearlyInspectionModifyBizDto> beanList) {
		List<YearlyInspectionModifyDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (YearlyInspectionModifyBizDto bean : beanList) {
				dtoList.add(toYearlyInspectionModifyDto(bean));
			}
		}

		return dtoList;
	}

	public static YearlyInspectionModifyDto toYearlyInspectionModifyDto(YearlyInspectionModifyBizDto bean) {
		YearlyInspectionModifyDto beanDto = null;
		if (bean != null) {

			beanDto = new YearlyInspectionModifyDto();
			BeanUtils.copyProperties(bean, beanDto);
			if(null != beanDto.getEndDate()) {
				LocalDateTime endDate = beanDto.getEndDate();
				LocalDate date = DateUtil.lastDayOfMonth(endDate.toLocalDate());
				beanDto.setEndDate(DateUtil.getDayEnd(date));
			}
		}
		return beanDto;
	}

	public static List<YearlyInspectionLogCreateDto> toYearlyInspectionLogCreateDto(List<YearlyInspectionDto> beanList,List<YearlyInspectionModifyBizDto> modifyList) {
		List<YearlyInspectionLogCreateDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			Map<Integer, YearlyInspectionModifyBizDto> yearlyInspectionModifyBizMap = modifyList.stream().collect(Collectors.toMap(YearlyInspectionModifyBizDto::getCarId, a -> a, (k1, k2) -> k1));
            LocalDateTime nowTime =LocalDateTime.now();
            for (YearlyInspectionDto bean : beanList) {
                YearlyInspectionModifyBizDto yearlyInspectionModifyBizDto = yearlyInspectionModifyBizMap.get(bean.getCarId());
                dtoList.add(toYearlyInspectionLogCreateDto(bean,yearlyInspectionModifyBizDto,nowTime));
			}
		}

		return dtoList;
	}

	public static YearlyInspectionLogCreateDto toYearlyInspectionLogCreateDto(YearlyInspectionDto bean,YearlyInspectionModifyBizDto yearlyInspectionModifyBizDto,LocalDateTime nowTime) {
		YearlyInspectionLogCreateDto beanDto = null;
		if (bean != null) {
			beanDto = new YearlyInspectionLogCreateDto();
			BeanUtils.copyProperties(bean, beanDto);
            beanDto.setQualificationCertificateUrl(yearlyInspectionModifyBizDto.getQualificationCertificateUrl());
            beanDto.setExpressNumber(yearlyInspectionModifyBizDto.getExpressNumber());
            beanDto.setCompleteDate(nowTime);
		}
		return beanDto;
	}

	public static YearlyInspectionLogCreateDto toYearlyInspectionLogCreateDto(YearlyInspectionDto bean,YearlyInspectionModifyDto modifyDto) {
		YearlyInspectionLogCreateDto beanDto = null;
		if (bean != null) {
			beanDto = new YearlyInspectionLogCreateDto();
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setHandleWay(modifyDto.getHandleWay());
			beanDto.setEndDate(modifyDto.getEndDate());
			beanDto.setQualificationCertificateUrl(modifyDto.getQualificationCertificateUrl());
			beanDto.setCompleteDate(LocalDateTime.now());
		}
		return beanDto;
	}

	/******************************************** 年检结果转换结束 *****************************/

	/******************************************** 保险结果转换开始 *****************************/
	public static List<CarInsuranceDto> toCompulsoryInsuranceDto(List<InsuranceDto> beanList, Map<Integer, CarDto> map,
			Map<Integer, InsuranceCommercialDto> insuranceCommercialDtoMap) {
		List<CarInsuranceDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (InsuranceDto bean : beanList) {
				dtoList.add(toCompulsoryInsuranceDto(bean, map, insuranceCommercialDtoMap));
			}
		}

		return dtoList;
	}

	public static CarInsuranceDto toCompulsoryInsuranceDto(InsuranceDto insuranceDto, Map<Integer, CarDto> map,
			Map<Integer, InsuranceCommercialDto> insuranceCommercialDtoMap) {
		CarInsuranceDto beanDto = null;
		if (insuranceDto != null) {
			beanDto = new CarInsuranceDto();
			BeanUtils.copyProperties(insuranceDto, beanDto);
			if (null != map && null != map.get(insuranceDto.getCarId())) {
				BeanUtils.copyProperties(map.get(insuranceDto.getCarId()), beanDto);
			}
			beanDto.setInsuranceId(insuranceDto.getId());
			if (insuranceDto.getType() == CarInsuranceTypeEnum.COMMERCIAL_INSURANCE.getValue()) {
				if(null != insuranceCommercialDtoMap) {
					InsuranceCommercialDto insuranceCommercialDto = insuranceCommercialDtoMap.get(insuranceDto.getId());
					if (null != insuranceCommercialDto) {
						//beanDto.setCost(insuranceCommercialDto.getCost());
						beanDto.setAmount(insuranceCommercialDto.getAmount());
					}
				}
			}

			if(beanDto.getEndTime().compareTo(LocalDateTime.now())>=0&&LocalDateTime.now().compareTo(beanDto.getBeginTime())>=0) {
				beanDto.setStatus(CarInsuranceStatusEnum.UNDER_WARRANTY.getValue());
				beanDto.setStatusStr(CarInsuranceStatusEnum.UNDER_WARRANTY.getName());
			}else if(LocalDateTime.now().compareTo(beanDto.getEndTime())>=0){
				beanDto.setStatus(CarInsuranceStatusEnum.OVER_INSURANCE.getValue());
				beanDto.setStatusStr(CarInsuranceStatusEnum.OVER_INSURANCE.getName());
			}else {
				beanDto.setStatus(CarInsuranceStatusEnum.INACTIVE_POLICY.getValue());
				beanDto.setStatusStr(CarInsuranceStatusEnum.INACTIVE_POLICY.getName());
			}

		}
		return beanDto;
	}

	public static CarInsuranceDetailDto toCarInsuranceDetailDto(InsuranceDto insuranceDto,
			List<InsuranceCommercialDto> insuranceCommercialDtoList, CarDto carDto) {
		CarInsuranceDetailDto beanDto = null;
		if (insuranceDto != null) {
			beanDto = new CarInsuranceDetailDto();
			BeanUtils.copyProperties(insuranceDto, beanDto);
			BeanUtils.copyProperties(carDto, beanDto);
			beanDto.setCommercialList(toCarInsuranceCommercialDto(beanDto, insuranceCommercialDtoList));
			beanDto.setInsuranceId(insuranceDto.getId());
		}
		return beanDto;
	}

	public static List<CarInsuranceCommercialDto> toCarInsuranceCommercialDto(CarInsuranceDetailDto beanDto,
			List<InsuranceCommercialDto> beanList) {
		List<CarInsuranceCommercialDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			BigDecimal amount = new BigDecimal("0");
			BigDecimal cost = new BigDecimal("0");
			for (InsuranceCommercialDto bean : beanList) {
				amount = amount.add(bean.getAmount());
				cost = cost.add(bean.getCost());
				dtoList.add(toCarInsuranceCommercialDto(bean));
			}
			//beanDto.setCost(cost);
			beanDto.setAmount(amount);
		}
		return dtoList;
	}

	public static CarInsuranceCommercialDto toCarInsuranceCommercialDto(InsuranceCommercialDto bean) {
		CarInsuranceCommercialDto beanDto = null;
		if (bean != null) {
			beanDto = new CarInsuranceCommercialDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}

	public static InsuranceModifyDto toInsuranceModifyDto(CarCompulsoryInsuranceModifyDto bean) {
		InsuranceModifyDto beanDto = null;
		if (bean != null) {
			beanDto = new InsuranceModifyDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}

	public static InsuranceModifyDto toInsuranceModifyDto(CarCommercialInsuranceModifyDto bean) {
		InsuranceModifyDto beanDto = null;
		if (bean != null) {
			beanDto = new InsuranceModifyDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}

	public static List<InsuranceCommercialModifyDto> toInsuranceCommercialModifyDto(
			List<CarInsuranceCommercialModifyDto> beanList) {
		List<InsuranceCommercialModifyDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (CarInsuranceCommercialModifyDto bean : beanList) {
				dtoList.add(toInsuranceCommercialModifyDto(bean));
			}
		}

		return dtoList;
	}

	public static InsuranceCommercialModifyDto toInsuranceCommercialModifyDto(CarInsuranceCommercialModifyDto bean) {
		InsuranceCommercialModifyDto beanDto = null;
		if (bean != null) {
			beanDto = new InsuranceCommercialModifyDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}

	public static CarDetailBizDto toCarDetailDto(CarDto bean, CarDetailDto carDetailDto,
			LicencePlateDto licencePlateDto) {
		CarDetailBizDto beanDto = null;
		if (bean != null) {
			beanDto = new CarDetailBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if (carDetailDto != null) {
				BeanUtils.copyProperties(carDetailDto, beanDto);
			}
			if (null != licencePlateDto) {
				beanDto.setRegisterCard(licencePlateDto.getRegisterCard());
				beanDto.setTaxProof(licencePlateDto.getTaxProof());
				beanDto.setDrivingLicense(licencePlateDto.getDrivingLicense());
			}
			beanDto.setCarId(bean.getId());
		}
		return beanDto;
	}

	/******************************************** 保险结果转换结束 *****************************/

	/******************************************** mybits-plus分页结果转换开始 *****************************/

	public static Paged<AccidentBizDto> toAccidentBizDto(Paged<AccidentDto> bean, Map<Integer, CarDto> carMap,
			Map<Integer, AccidentCaseDto> accidentCaseMap) {
		Paged<AccidentBizDto> beanDto = null;
		if (bean != null) {
			beanDto = new Paged<>();
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setList(toAccidentBizDto(bean.getList(), carMap, accidentCaseMap));
		}
		return beanDto;
	}

	public static List<AccidentBizDto> toAccidentBizDto(List<AccidentDto> beanList, Map<Integer, CarDto> carMap,
			Map<Integer, AccidentCaseDto> accidentCaseMap) {
		List<AccidentBizDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (AccidentDto bean : beanList) {
				dtoList.add(toAccidentBizDto(bean, carMap, accidentCaseMap));
			}
		}

		return dtoList;
	}

	public static AccidentBizDto toAccidentBizDto(AccidentDto bean, Map<Integer, CarDto> carMap,
			Map<Integer, AccidentCaseDto> accidentCaseMap) {
		AccidentBizDto beanDto = null;
		if (bean != null) {
			beanDto = new AccidentBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if ((null != carMap) && (null != carMap.get(bean.getCarId()))) {
				CarDto carDto = carMap.get(bean.getCarId());
				beanDto.setLicencePlate(carDto.getLicencePlate());
				beanDto.setVin(carDto.getVin());
				beanDto.setVehicleId(carDto.getVehicleId()+"");
			}
			if ((null != accidentCaseMap) && (null != accidentCaseMap.get(bean.getId()))) {
				AccidentCaseDto accidentCaseDto = accidentCaseMap.get(bean.getId());
				beanDto.setSettleTime(accidentCaseDto.getSettleTime());
				beanDto.setCommitSettleTime(accidentCaseDto.getOperationTime());
			}
			beanDto.setAccidentId(bean.getId());

		}
		return beanDto;
	}

	public static void toAccidentImage(AccidentDetailDto accidentDetailDto, AccidentDriveDto accidentDriveDto,
									   Map<Integer, List<AccidentImageDto>> accidentImageMap,AccidentDto accidentDto) {
		List<com.molichuxing.services.business.dto.response.AccidentImageDto> accidentImageListResult = new ArrayList<>();
		if (null != accidentDriveDto) {
			if((StringUtils.isNotEmpty(accidentDriveDto.getIdCardFront())||StringUtils.isNotEmpty(accidentDriveDto.getIdCardReverse()))){
				com.molichuxing.services.business.dto.response.AccidentImageDto idCardImage = new com.molichuxing.services.business.dto.response.AccidentImageDto();
				idCardImage.setKey(CarAccidentImageEnum.ID_CARD.getValue() + "");
				idCardImage.setImageName(CarAccidentImageEnum.ID_CARD.getName());
				List<String> imgList = new ArrayList<>();
				if(StringUtils.isNotEmpty(accidentDriveDto.getIdCardFront())) {
					imgList.add(accidentDriveDto.getIdCardFront());
				}
				if(StringUtils.isNotEmpty(accidentDriveDto.getIdCardReverse())) {
					imgList.add(accidentDriveDto.getIdCardReverse());
				}
				idCardImage.setImageList(imgList);
				accidentImageListResult.add(idCardImage);
			}

			if((StringUtils.isNotEmpty(accidentDriveDto.getDrivingLicenseFront())||StringUtils.isNotEmpty(accidentDriveDto.getDrivingLicenseReverse()))) {
				com.molichuxing.services.business.dto.response.AccidentImageDto driverCardImage = new com.molichuxing.services.business.dto.response.AccidentImageDto();
				driverCardImage.setKey(CarAccidentImageEnum.DRIVER_CARD.getValue() + "");
				driverCardImage.setImageName(CarAccidentImageEnum.DRIVER_CARD.getName());
				List<String> imgList = new ArrayList<>();
				if(StringUtils.isNotEmpty(accidentDriveDto.getDrivingLicenseFront())) {
					imgList.add(accidentDriveDto.getDrivingLicenseFront());
				}
				if(StringUtils.isNotEmpty(accidentDriveDto.getDrivingLicenseReverse())) {
					imgList.add(accidentDriveDto.getDrivingLicenseReverse());
				}
				driverCardImage.setImageList(imgList);
				accidentImageListResult.add(driverCardImage);
			}
		}

		List<com.molichuxing.services.business.dto.response.AccidentImageDto> caseImageList = new ArrayList<>();
		List<Integer> accidentEnums = Arrays.asList(CarAccidentImageEnum.PANORAMA_WOUNDED.getValue(),
				CarAccidentImageEnum.DETAILS_INJURED_AREA.getValue(),
				CarAccidentImageEnum.VEHICLE_DEGREE_ANGLE.getValue(),CarAccidentImageEnum.ACCIDENT_PANORAMA.getValue(),
				CarAccidentImageEnum.FRAME_NUMBER_PHOTO.getValue(), CarAccidentImageEnum.INTERIOR_PHOTO.getValue(),
				CarAccidentImageEnum.COLLISION_DETAILS.getValue(), CarAccidentImageEnum.SCATTERED_PARTS.getValue());
		if ((null != accidentImageMap) && (accidentImageMap.size() > 0)) {
			for (Integer key : accidentImageMap.keySet()) {
				com.molichuxing.services.business.dto.response.AccidentImageDto accidentImageDto = null;
				com.molichuxing.services.business.dto.response.AccidentImageDto caseImageDto = null;
				List<String> imageList = new ArrayList<>();
				for (AccidentImageDto dto : accidentImageMap.get(key)) {
					if (accidentEnums.contains(dto.getType())) {
						accidentImageDto = new com.molichuxing.services.business.dto.response.AccidentImageDto();
						accidentImageDto.setKey(CarAccidentImageEnum.getEnum(dto.getType()).getValue() + "");
						accidentImageDto.setImageName(CarAccidentImageEnum.getName(dto.getType()));
						imageList.add(dto.getRelativePath());
						accidentImageDto.setImageList(imageList);
					} else {
						caseImageDto = new com.molichuxing.services.business.dto.response.AccidentImageDto();
						caseImageDto.setKey(CarAccidentImageEnum.getEnum(dto.getType()).getValue() + "");
						caseImageDto.setImageName(CarAccidentImageEnum.getName(dto.getType()));
						imageList.add(dto.getRelativePath());
						caseImageDto.setImageList(imageList);
					}
				}
				if (null != accidentImageDto) {
					accidentImageListResult.add(accidentImageDto);
				}
				if (null != caseImageDto) {
					caseImageList.add(caseImageDto);
				}
			}
		}
		if(null != accidentDto.getRelativePath()) {
			com.molichuxing.services.business.dto.response.AccidentImageDto accidentLiabilityImageDto = new com.molichuxing.services.business.dto.response.AccidentImageDto();
			accidentLiabilityImageDto.setKey(CarAccidentImageEnum.LIABILITY_TYPE.getValue() + "");
			accidentLiabilityImageDto.setImageName(CarAccidentImageEnum.LIABILITY_TYPE.getName());
			accidentLiabilityImageDto.setImageList(Arrays.asList(accidentDto.getRelativePath()));
			accidentImageListResult.add(accidentLiabilityImageDto);
		}
		accidentDetailDto.setAccidentImageList(accidentImageListResult);
		accidentDetailDto.setCaseImageList(caseImageList);
	}

	public static void toCommitAccident(AccidentDetailDto accidentDetailDto, AccidentDto accidentDto,
			AccidentCaseDto accidentCaseDto) {
		AccidentCommitDto commit = new AccidentCommitDto();
		commit.setAccidentCheckUser(accidentDto.getAccountAccount());
		commit.setAccidentCheckDesc(accidentDto.getRemark());
		commit.setAccidentCheckTime(accidentDto.getOperationTime());
		if (null != accidentCaseDto) {
			commit.setCaseCheckUser(accidentCaseDto.getAccountAccount());
			commit.setCaseCheckDesc(accidentCaseDto.getExmineRemark());
			commit.setCaseCheckTime(accidentCaseDto.getOperationTime());
		}
		accidentDetailDto.setCommit(commit);
	}

	public static void toUserAccident(AccidentDetailDto accidentDetailDto, AccidentDto accidentDto, CarDto carDto,
			List<InsuranceDto> insuranceList) {
		AccidentCarUserDto accidentCarUserDto = new AccidentCarUserDto();
		accidentCarUserDto.setVin(carDto.getVin());
		accidentCarUserDto.setUserId(accidentDto.getUserId());
		accidentCarUserDto.setCompulsoryCode(accidentDto.getCompulsoryCode());
		accidentCarUserDto.setCommercialCode(accidentDto.getCommercialCode());
		accidentCarUserDto.setOrderCode(accidentDto.getOrderCode());
		accidentCarUserDto.setLicencePlate(carDto.getLicencePlate());
		if ((null != insuranceList) && (insuranceList.size() > 0)) {
			for (InsuranceDto insuranceDto : insuranceList) {
				if (insuranceDto.getType() == CarInsuranceTypeEnum.COMMERCIAL_INSURANCE.getValue()) {
					accidentCarUserDto.setCommercialCompanyId(insuranceDto.getInsuranceCompanyId());
				} else if (insuranceDto.getType() == CarInsuranceTypeEnum.COMPULSORY_INSURANCE.getValue()) {
					accidentCarUserDto.setCompulsoryCompanyId(insuranceDto.getInsuranceCompanyId());
				}
			}
		}
		accidentDetailDto.setAccidentCarUserDto(accidentCarUserDto);
	}

	public static void toAccidentStatusDto(AccidentDetailDto accidentDetailDto, AccidentDto accidentDto,
			AccidentCaseDto accidentCaseDto) {
		Map<Integer, AccidentStatusDto> statusMap = new HashMap<>();
		AccidentStatusDto dto = new AccidentStatusDto();

		if (accidentDto.getStatus() == CarAccidentStatusEnum.INVALID_REPORT.getValue()) {
			dto.setStatus(CarAccidentStatusEnum.ACCIDENT_NOT_CONFIRMED.getValue());
			dto.setSelected(BasicEnum.YES.getValue());
			dto.setDateTime(accidentDto.getAccidentTime());
			statusMap.put(CarAccidentStatusEnum.ACCIDENT_NOT_CONFIRMED.getValue(), dto);

			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.INVALID_REPORT.getValue());
			dto.setDateTime(accidentDto.getOperationTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.INVALID_REPORT.getValue(), dto);
			accidentDetailDto.setStatus(statusMap);
			return;
		}
		for (CarAccidentStatusEnum enumerate : CarAccidentStatusEnum.values()) {
			if (enumerate != CarAccidentStatusEnum.ALL && CarAccidentStatusEnum.INVALID_REPORT != enumerate) {
				dto = new AccidentStatusDto();
				dto.setStatus(enumerate.getValue());
				dto.setSelected(BasicEnum.NO.getValue());
				if (CarAccidentStatusEnum.ACCIDENT_NOT_CONFIRMED == enumerate) {
					dto.setSelected(BasicEnum.YES.getValue());
					dto.setDateTime(accidentDto.getAccidentTime());
				}
				statusMap.put(enumerate.getValue(), dto);
			}
		}
		if (accidentDto.getStatus() == CarAccidentStatusEnum.ACCIDENT_NOT_CONFIRMED.getValue()) {
			accidentDetailDto.setStatus(statusMap);
			return;
		}

		if (accidentDto.getStatus() == CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue()) {
			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue());
			dto.setDateTime(accidentDto.getOperationTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue(), dto);
		} else if (accidentDto.getStatus() == CarAccidentStatusEnum.CASE_NOT_CONFIRMED.getValue()) {
			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue());
			dto.setDateTime(accidentDto.getOperationTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue(), dto);

			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.CASE_NOT_CONFIRMED.getValue());
			dto.setDateTime(accidentCaseDto.getSettleTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.CASE_NOT_CONFIRMED.getValue(), dto);
		} else if (accidentDto.getStatus() == CarAccidentStatusEnum.CASE_CLOSED.getValue()) {
			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue());
			dto.setDateTime(accidentDto.getOperationTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.ACCIDENT_CONFIRMED.getValue(), dto);

			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.CASE_NOT_CONFIRMED.getValue());
			dto.setDateTime(accidentCaseDto.getSettleTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.CASE_NOT_CONFIRMED.getValue(), dto);

			dto = new AccidentStatusDto();
			dto.setStatus(CarAccidentStatusEnum.CASE_CLOSED.getValue());
			dto.setDateTime(accidentCaseDto.getOperationTime());
			dto.setSelected(BasicEnum.YES.getValue());
			statusMap.put(CarAccidentStatusEnum.CASE_CLOSED.getValue(), dto);
		}
		accidentDetailDto.setStatus(statusMap);
	}

	// app事故详情-基础信息
	public static AccidentAppBizDto toAccidentAppBizDto(AccidentDto dto) {
		AccidentAppBizDto bizDto = null;
		if (dto != null) {
			bizDto = new AccidentAppBizDto();
			BeanUtils.copyProperties(dto, bizDto);
		}
		return bizDto;
	}

	// app事故详情-驾驶人信息
	public static AccidentDriveAppBizDto toAccidentDriveAppBizDto(AccidentDriveDto dto) {
		AccidentDriveAppBizDto bizDto = null;
		if (dto != null) {
			bizDto = new AccidentDriveAppBizDto();
			BeanUtils.copyProperties(dto, bizDto);
		}
		return bizDto;
	}

	// app事故详情-图片信息
	public static List<AccidentImageAppBizDto> toAccidentImageAppBizDto(List<CarAccidentImageEnum> carAccidentImageEnum,
			Map<Integer, List<AccidentImageDto>> accidentImageMap) {
		List<AccidentImageAppBizDto> accidentImageAppBizDtoList = new ArrayList<>();
		if (null == accidentImageMap || accidentImageMap.size() <= 0) {
			return accidentImageAppBizDtoList;
		}
		AccidentImageAppBizDto accidentImageAppBizDto = null;
		List<String> imgStrList = null;
		for (CarAccidentImageEnum imageEnum : carAccidentImageEnum) {
			accidentImageAppBizDto = new AccidentImageAppBizDto();

			List<AccidentImageDto> accidentImageDtoList = accidentImageMap.get(imageEnum.getValue());
			accidentImageAppBizDto.setType(imageEnum.getValue());
			accidentImageAppBizDto.setImageName(imageEnum.getName());
			if (null == accidentImageDtoList || accidentImageDtoList.size() <= 0) {
				accidentImageAppBizDto.setCount(0);
			} else {
				imgStrList = new ArrayList<>();
				for (AccidentImageDto accidentImageDto : accidentImageDtoList) {
					imgStrList.add(accidentImageDto.getRelativePath());
				}
				accidentImageAppBizDto.setImageList(imgStrList);
				accidentImageAppBizDto.setCount(accidentImageDtoList.size());
			}
			accidentImageAppBizDtoList.add(accidentImageAppBizDto);
		}

		return accidentImageAppBizDtoList;
	}

	// app结案信息
	public static AccidentCaseAppDto toAccidentCaseAppDto(AccidentCaseDto dto) {
		AccidentCaseAppDto bizDto = null;
		if (dto != null) {
			bizDto = new AccidentCaseAppDto();
			BeanUtils.copyProperties(dto, bizDto);
		}
		return bizDto;
	}

	/******************************************** mybits-plus分页结果转换结束 *****************************/

	public static void toMaintenanceBizDto(Paged<MaintenanceBizDto> beanDto, Paged<MaintenanceDto> bean,Map<Integer, MaintenanceLogDto> submitUserMap) {
		if (bean != null) {
			bean.setTab(beanDto.getTab());
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setList(toMaintenanceBizDto(bean.getList(), submitUserMap));
		}
	}

	public static List<MaintenanceBizDto> toMaintenanceBizDto(List<MaintenanceDto> beanList,Map<Integer, MaintenanceLogDto> submitUserMap) {
		List<MaintenanceBizDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (MaintenanceDto bean : beanList) {
				dtoList.add(toMaintenanceBizDto(bean,submitUserMap));
			}
		}

		return dtoList;
	}

	public static MaintenanceBizDto toMaintenanceBizDto(MaintenanceDto bean,Map<Integer, MaintenanceLogDto> submitUserMap) {
		MaintenanceBizDto beanDto = null;
		if (bean != null) {
			beanDto = new MaintenanceBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setSubmitDate(bean.getGmtCreate());
			beanDto.setId(bean.getId());
			beanDto.setMaintenanceId(bean.getId());
			if(null != submitUserMap && null != submitUserMap.get(bean.getId())) {
				if(null != submitUserMap.get(bean.getId()).getUserId()) {
					beanDto.setOperationType(submitUserMap.get(bean.getId()).getUserType());
					beanDto.setOperationId(submitUserMap.get(bean.getId()).getUserId()+"");
				}
			}
		}
		return beanDto;
	}

	public static void toMaintenanceLogBizDto(Paged<MaintenanceBizDto> beanDto, Paged<MaintenanceLogDto> bean) {
		if (bean != null) {
			bean.setTab(beanDto.getTab());
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setList(toMaintenanceLogBizDto(bean.getList()));
		}
	}

	public static List<MaintenanceBizDto> toMaintenanceLogBizDto(List<MaintenanceLogDto> beanList) {
		List<MaintenanceBizDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (MaintenanceLogDto bean : beanList) {
				dtoList.add(toMaintenanceLogBizDto(bean));
			}
		}

		return dtoList;
	}

	public static MaintenanceBizDto toMaintenanceLogBizDto(MaintenanceLogDto bean) {
		MaintenanceBizDto beanDto = null;
		if (bean != null) {
			beanDto = new MaintenanceBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			beanDto.setId(bean.getId());
			beanDto.setMaintenanceId(bean.getMaintenanceId());
			if(null != bean.getSettlementUrl()) {
		        beanDto.setSettlementUrl(JSONObject.parseArray(bean.getSettlementUrl(), String.class));
		    }
		}
		return beanDto;
	}

	public static MaintenanceBasicBizDto toMaintenanceBasicBizDto(MaintenanceDto bean, CarDto carDto) {
		MaintenanceBasicBizDto beanDto = null;
		if (bean != null) {
			beanDto = new MaintenanceBasicBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if (null != carDto) {
				beanDto.setLicencePlate(carDto.getLicencePlate());
				beanDto.setVin(carDto.getVin());
				beanDto.setVehicleType(carDto.getVehicleType());
				beanDto.setVehicleId(carDto.getVehicleId());
				beanDto.setMaintainableDate(bean.getMaintainableDate());
				Long duration =DateUtil.getDaysDiff(bean.getMaintainableDate().toLocalDate(), LocalDate.now());
				if (duration > 0) {
					beanDto.setMaintainableOverDate(duration);
				} else {
					beanDto.setMaintainableOverDate(0L);
				}
				beanDto.setUserId(bean.getUserId());
			}
		}
		return beanDto;
	}

	public static List<MaintenanceRecordBizDto> toMaintenanceRecordBizDto(List<MaintenanceLogDto> beanList) {
		List<MaintenanceRecordBizDto> dtoList = null;
		;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (MaintenanceLogDto bean : beanList) {
				dtoList.add(toMaintenanceRecordBizDto(bean));
			}
		}

		return dtoList;
	}

	public static MaintenanceRecordBizDto toMaintenanceRecordBizDto(MaintenanceLogDto bean) {
		MaintenanceRecordBizDto beanDto = null;
		if (bean != null) {
			beanDto = new MaintenanceRecordBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if(null != bean.getSettlementUrl()) {
				beanDto.setSettlementUrl(JSONObject.parseArray(bean.getSettlementUrl(), String.class));
			}
		}
		return beanDto;
	}

	public static MaintenanceInfoBizDto toMaintenanceInfoBizDto(MaintenanceLogDto bean) {
		MaintenanceInfoBizDto beanDto = null;
		if (bean != null) {
			beanDto = new MaintenanceInfoBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if(null != bean) {
				beanDto.setSettlementUrl(JSONObject.parseArray(bean.getSettlementUrl(), String.class));
			}
		}
		return beanDto;
	}

	public static PdiCheckBizDto toPdiCheckVo(CheckDto bean, CheckDisputeDto checkDisputeDto,
			CheckImageDto checkImageDto) {
		PdiCheckBizDto beanDto = null;
		if (bean != null) {
			beanDto = new PdiCheckBizDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		if (checkDisputeDto != null) {
			beanDto.setDiscussLossFee(checkDisputeDto.getDiscussLossFee());
			beanDto.setDiscussremark(checkDisputeDto.getRemark());
			beanDto.setDisputeCheckTime(checkDisputeDto.getCheckTime());
			beanDto.setIsUserApproves(checkDisputeDto.getIsUserApproves());
		}
		if (checkImageDto != null) {
			BeanUtils.copyProperties(checkImageDto, beanDto);
		}
		return beanDto;
	}

	public static HandoverCreateDto toHandoverCreateDto(HandoverCreateBizDto createBizDto) {
		HandoverCreateDto createDto = null;
		if (createBizDto != null) {
			createDto = new HandoverCreateDto();
			BeanUtils.copyProperties(createBizDto, createDto);
		}
		return createDto;
	}

	public static HandoverModifyDto totoHandoverModifyDto(HandoverCreateBizDto createBizDto, HandoverDto handoverDto) {
		HandoverModifyDto modifyDto = null;
		if (createBizDto != null) {
			modifyDto = new HandoverModifyDto();
			BeanUtils.copyProperties(createBizDto, modifyDto);
			modifyDto.setId(handoverDto.getId());
		}
		return modifyDto;
	}

	public static CheckCreateDto toCheckCreateDto(ReturnCarModifyBizDto modifyBizDto) {
		if (modifyBizDto == null) {
			return null;
		}
		CheckCreateDto createDto = new CheckCreateDto();
		// 检验类型
		createDto.setType(modifyBizDto.getCheckType() == null ? CarCheckTypeEnum.PDI : modifyBizDto.getCheckType());
		// 订单号
		 createDto.setOrderCode(modifyBizDto.getHandover().getOrderCode());
		 // 还车门店id
		createDto.setReturnStoreId(modifyBizDto.getHandover().getStoreId());
		// 经销商id
		createDto.setDealerId(modifyBizDto.getHandover().getDealerId());
		 // 车辆ID
		createDto.setCarId(modifyBizDto.getCarId());
		 // 车辆类型
		createDto.setCarType(modifyBizDto.getCarType());
		 // 公里数,已行驶里程数
		createDto.setMileage(new BigDecimal(modifyBizDto.getHandover().getMileage()));

		return createDto;
	}

	public static List<CarBizDto> toCarBizDto(List<CarDto> beanList,Map<Integer, CarDetailDto> carDetailMap) {
		List<CarBizDto> dtoList = null;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (CarDto bean : beanList) {
				dtoList.add(toCarBizDto(bean,carDetailMap));
			}
		}

		return dtoList;
	}

	public static CarBizDto toCarBizDto(CarDto bean,Map<Integer, CarDetailDto> carDetailMap) {
		CarBizDto beanDto = null;
		if (bean != null) {
			beanDto = new CarBizDto();
			BeanUtils.copyProperties(bean, beanDto);
			if(null == carDetailMap || carDetailMap.size() < 1){
				return beanDto;
			}

			CarDetailDto carDetailDto = carDetailMap.get(bean.getId());
			if(null == carDetailDto){
				return beanDto;
			}
			beanDto.setEngineCode(carDetailDto.getEngineCode());
		}
		return beanDto;
	}

	public static List<CarInsuranceDto> toCarInsuranceDto(List<InsuranceDto> beanDtos) {
		List<CarInsuranceDto> beanBizDtos = null;
		if (beanDtos == null || beanDtos.isEmpty()) {
			return beanBizDtos;
		}
		beanBizDtos = new ArrayList<>(beanDtos.size());

		for (InsuranceDto beanDto : beanDtos) {
			beanBizDtos.add(toCarInsuranceDto(beanDto));
		}

		return beanBizDtos;
	}

	public static CarInsuranceDto toCarInsuranceDto(InsuranceDto beanDto) {
		CarInsuranceDto beanBizDto = null;
		if (beanDto == null) {
			return beanBizDto;
		}
		beanBizDto = new CarInsuranceDto();
		BeanUtils.copyProperties(beanDto, beanBizDto);
		beanBizDto.setInsuranceId(beanDto.getId());

		return beanBizDto;
	}

	public static CarInsuranceDetailDto toCarInsuranceDetailDto(InsuranceDto beanDto) {
		CarInsuranceDetailDto beanBizDto = null;
		if (beanDto == null) {
			return beanBizDto;
		}
		beanBizDto = new CarInsuranceDetailDto();
		BeanUtils.copyProperties(beanDto, beanBizDto);
		beanBizDto.setInsuranceId(beanDto.getId());

		return beanBizDto;
	}


	public static List<CarFenceExceptionBizDto> toCarFenceExceptionBizDto(List<FenceExceptionDto> beanDtoList, Map<Integer, CarDto> carMap) {
		List<CarFenceExceptionBizDto>  dtoList = null;
		if (beanDtoList != null && (beanDtoList.size() > 0)) {
			dtoList = new ArrayList<>();
			for(FenceExceptionDto fenceExceptionDto : beanDtoList) {
				dtoList.add(toCarFenceExceptionBizDto(fenceExceptionDto, carMap));
			}
		}
		return dtoList;
	}


	public static CarFenceExceptionBizDto toCarFenceExceptionBizDto(FenceExceptionDto beanDto, Map<Integer, CarDto> carMap) {
		CarFenceExceptionBizDto  dto = null;
		if (beanDto != null) {
			dto = new CarFenceExceptionBizDto();
				BeanUtils.copyProperties(beanDto, dto);
				if((null != carMap)&&(null != carMap.get(beanDto.getCarId()))) {
					CarDto carDto = carMap.get(beanDto.getCarId());
					dto.setVehicleId(carDto.getVehicleId());
					dto.setVin(carDto.getVin());
					dto.setLicencePlate(carDto.getLicencePlate());
				}
		}
		return dto;
	}

}
